<%@ page import="com.example.demo.Student.Student" %>
<%@ page import="java.util.List" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>学生列表分页展示</title>
</head>
<body>
<h2>学生列表</h2>
<table border="1">
    <tr>
        <th>ID</th>
        <th>姓名</th>
        <th>年龄</th>
    </tr>
    <c:if test="${not empty studentList}">
        <c:forEach var="student" items="${studentList}">
            <tr>
                <td>${student.id}</td>
                <td>${student.name}</td>
                <td>${student.age}</td>
            </tr>
        </c:forEach>
    </c:if>
</table>
<div>
    当前第 ${empty param.pageNum ? 1 : param.pageNum} 页，共 ${empty totalPages ? 1 : totalPages} 页
    <c:set var="currentPage" value="${empty param.pageNum ? 1 : param.pageNum}" />
    <c:if test="${currentPage > 1}">
        <a href="student?pageNum=${currentPage - 1}">上一页</a>
    </c:if>
    <c:if test="${currentPage < (empty totalPages ? 1 : totalPages)}">
        <a href="student?pageNum=${currentPage + 1}">下一页</a>
    </c:if>
</div>
</body>
</html>